//
//  NSDay.m
//  KongDays
//
//  Created by deeplu on 13. 1. 7..
//  Copyright (c) 2013년 BlueBeans. All rights reserved.
//

#import "NSDay.h"


@implementation NSDay

@dynamic date;
@dynamic memo;
@dynamic picture;
@dynamic title;
@dynamic repeat;

- (NSString *)dateToString
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    
    if ([self.repeat isEqualToString:@"year"]) {
        [formatter setDateFormat:NSLocalizedString(@"Every Year Date Format", nil)];
    } else if ([self.repeat isEqualToString:@"month"]) {
        [formatter setDateFormat:NSLocalizedString(@"Every Month Date Format", nil)];
    } else {
        [formatter setDateFormat:NSLocalizedString(@"Short Date Format", nil)];
    }
    
    NSString *text = [formatter stringFromDate:self.date];
    
    [formatter release];
    
    return text;
}

- (NSInteger)daysCount
{
    if (self.date != nil) {
        return [self.date timeIntervalSinceNow] / (60.0 * 60.0 * 24.0);
    }
    
    return (0);
}

- (NSString *)daysCountText
{
    return [NSString stringWithFormat:@"%i", [self daysCount]];
}
@end
